#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:robot
@file: bfs_grapht.py 
@version:
@time: 2024/01/27 
"""
from collections import deque


class BFSGraph:
    def __init__(self, point, graph):
        self.graph = graph
        self.point = point
        self.visited = [0] * len(graph)

    def bfs_graph(self):
        queue = deque([0])
        self.visited[0] = 1
        while queue:
            node_index = queue.popleft()
            print(self.point[node_index])
            for i in range(len(self.graph)):
                if self.graph[node_index][i] == 1 and self.visited[i] == 0:
                    queue.append(i)
                    self.visited[i] = 1